import 'dart:io';

import 'package:flutter/material.dart';

void main() {
  runApp(new GridViewPlugin());
}

/*
 * 网格布局 <br/>
 * 需要传入的键：<br/>
 * 传入的值类型： <br/>
 * 传入的值含义：<br/>
 * 是否必传 ：
 */
class GridViewPlugin extends StatefulWidget {
  State<StatefulWidget> createState() {
    return new GridViewPluginState();
  }
}

/*
 * 页面功能 <br/>
 */
class GridViewPluginState extends State<StatefulWidget> {
  bool check = true;

  void initState() {
    super.initState();
  }

  Widget build(BuildContext context) {
    AppBar appBar = AppBar(
      leading: new IconButton(
        icon: new Icon(Icons.arrow_back),
        onPressed: () {},
      ),
      title: new Text('FlutterDesign'),
      centerTitle: true,
      actions: <Widget>[
        new Container(width: 0, height: 0),
        new Container(width: 0, height: 0),
      ],
      backgroundColor: Colors.blue,
    );

    return MaterialApp(
      home: new Scaffold(
        appBar: appBar,
        body: new Builder(builder: (BuildContext context) {
          return GridView.count(
            //水平子Widget之间间距
            crossAxisSpacing: 10.0,
            //垂直子Widget之间间距
            mainAxisSpacing: 30.0,
            //GridView内边距
            padding: EdgeInsets.all(10.0),
            //一行的Widget数量
            crossAxisCount: 2,
            //子Widget宽高比例
            childAspectRatio: 2.0,
            children: <Widget>[
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
              Padding(
                padding: EdgeInsets.all(20),
                child: Text('测试'),
              ),
            ],
          );
        }),
        backgroundColor: Colors.white,
        bottomNavigationBar: null,
      ),
    );
  }
}
